import { checkLogin, getUserByAccount } from "@/apis/login"
import { setUserInfo } from "./cookieMgr";

export const isLogin=async()=>{
    try{
        const res=await checkLogin();
        const res2=await getUserByAccount();
        if(res.code>=0&&res2.code>=0){
            var userInfo=res.data;
            userInfo.user=res2.data;
            setUserInfo(userInfo)
            return true;
        }else{
            uni.redirectTo({
                url:"/pages/login/login"
            })
            return false;
        }
    }catch{
        uni.redirectTo({
            url:"/pages/login/login"
        })
        return false;
    }
    
}